package com.humanmonth.home.component.page.msg
{
	import com.humanmonth.home.component.page.msg.remote.Connector;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import mx.binding.utils.BindingUtils;
	import mx.collections.XMLListCollection;
	import mx.controls.Alert;
	import mx.events.FlexEvent;
	import mx.utils.StringUtil;
	
	public class MsgAs extends Msg
	{
		/**
		 *所有留言 
		 */
		[Bindable]
		public static var msgs:XMLListCollection=new XMLListCollection();
		public function MsgAs()
		{
			super();
			this.addEventListener(FlexEvent.CREATION_COMPLETE,myInit);
		}
		
		private function myInit(event:Event):void{
			new Connector().getMsgs();
			this.confirmM.addEventListener(MouseEvent.CLICK,sendMsg);
		}
		
		private function sendMsg(event:Event):void{
			if(StringUtil.trim(this.nameM.text)==""||this.nameM.text.length>10){
				Alert.show("姓名不能为空，且长度要少于10");
				return;
			}
			if(StringUtil.trim(this.contactM.text)==""){
				Alert.show("联系方式不能为空，且长度要小于100");
				return;
			}
			if(StringUtil.trim(this.contentM.text)==""){
				Alert.show("内容不能为空，且长度要小于200");
				return;
			}
			new Connector().postMsg(this.nameM.text,this.contactM.text,this.contentM.text);
			this.nameM.text="";
			this.contentM.text="";
			this.contactM.text="";
		}
	}
}